<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>编辑账户</title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<link rel="stylesheet" type="text/css" href="assets/layui/css/layui.css" />
		<link rel="stylesheet" type="text/css" href="assets/css/all.css"  />
		<style>
			.layui-input-4 {
			    width: 600px;
			    float: left;
			}
		</style>
	</head
<body>
	<!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
	<!--[if lt IE 9]>
		  <script src="assets/js/html5.min.js"></script>
		  <script src="assets/js/respond.min.js"></script>
		<![endif]-->
	<div class="layui-fluid">   
	    <form class="layui-form" action="" onsubmit="return false;">
	   		 <div class="layui-form-item">
	            <label class="layui-form-label">用户名</label>
	            <div class="layui-input-4">
	                <input type="text" name="name" lay-verify="required" value="beijing" class="layui-input">
	            </div>
	        </div>
	        <div class="layui-form-item">
	            <label class="layui-form-label">所属部门</label>
	            <div class="layui-input-4">
	                <input id="department" type="text" name="company" class="layui-input" value="山西分公司" lay-verify="required"> 
	            </div>
	        </div>
			<div class="layui-form-item">
	            <label class="layui-form-label">密码</label>
	            <div class="layui-input-4">
	                <input type="password" name="psw" class="layui-input" value="123456" lay-verify="required|psw">
	            </div>
	        </div>
	        <div class="layui-form-item">
	            <label class="layui-form-label">邮箱</label>
	            <div class="layui-input-4">
	                <input type="text" name="email"  value="957@qq.com" class="layui-input" lay-verify="required|mailAddress">
	            </div>
	        </div>
	        <div class="layui-form-item">
	            <label class="layui-form-label">手机号</label>
	            <div class="layui-input-4">
	                <input type="text" name="phone"  value="13641138223" class="layui-input" lay-verify="required|phoneNum">
	            </div>
	        </div>
	        <div class="layui-form-item" >
			    <label class="layui-form-label">角色</label>
			    <div class="layui-input-inline" style="width:600px;">
		       		<input type="radio" checked="checked" name="role" class="layui-input"  lay-skin="primary" title="财务" >
		       		<input type="radio" name="role" class="layui-input"  lay-skin="primary" title="运营">
		       		<input type="radio" name="role" class="layui-input"  lay-skin="primary" title="财务">
		       		<input type="radio" name="role" class="layui-input"  lay-skin="primary" title="运营">
		       		<input type="radio" name="role" class="layui-input"  lay-skin="primary" title="财务">
		       		<input type="radio" name="role" class="layui-input"  lay-skin="primary" title="运营">
		       		<input type="radio" name="role" class="layui-input"  lay-skin="primary" title="财务">
		       		<input type="radio" name="role" class="layui-input"  lay-skin="primary" title="运营">
		       		<input type="radio" name="role" class="layui-input"  lay-skin="primary" title="财务">
		       		<input type="radio" name="role" class="layui-input"  lay-skin="primary" title="运营">
		       	</div>
			</div>
			<div class="layui-form-item" >
			    <label class="layui-form-label">状态</label>
			    <div class="layui-input-inline">
		       		<input type="radio" checked="checked" name="statu" class="layui-input"  lay-skin="primary" title="禁用">
		       		<input type="radio" name="statu" class="layui-input"  lay-skin="primary" title="正常">
		       	</div>
			</div>
	        <div class="layui-form-item">
	            <div class="layui-input-block">
	                <button type="button" class="layui-btn" lay-submit="" lay-filter="submit-btn">确定</button>
	                <button class="layui-btn freshBtn layui-btn-danger">重置</button>
	            </div>
	        </div>
	    </form>
	</div>
	<script src="assets/layui/layui.js" type="text/javascript"></script>
	<script src="assets/js/all.js" type="text/javascript"></script>
	<script type="text/javascript">
		layui.use(['layer','form'],function(){
			var layer = layui.layer,
				form = layui.form,
				$ = layui.$
			
			//自定义验证规则
			form.verify({
				psw:[/^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,20}$/,'密码必须是6到20位的数字和字母'],
				mailAddress:[/^[A-Za-z\d]+([-_.][A-Za-z\d]+)*@([A-Za-z\d]+[-.])+[A-Za-z\d]{2,4}$/,'您输入的电子邮件地址不合法'],		
				phoneNum:[/^1\d{10}$/,'您输入的手机号码不合法']
			});
			//监听提交
			form.on('submit(submit-btn)', function(data) {
				$.ajax({
					type:"post",
					url:"{:U('manager/System/site')}",
					data:data.field,
					dataType:"json",
					success:function(data){
						if (data.code == 1) {
							layer.msg(data.msg,{icon:6,time:1000}, function(){
								top.location.reload();
							});
						} else {
							layer.msg(data.msg, {icon:5,time:1000});
						}
					},
					error: function(jqXHP,textStatus,errorThrown){
	                    layer.alert(jqXHP.responseText);
	                }
				});
				return false;
			});

			$("#department").click(function(){
				var index = layer.open({
					type:2,
					area:['500px','400px'],
					content:'chooseDepart.html',
					btn:["确认"],
					yes:function(idnex,layero){
						var body = layer.getChildFrame('body', index);
		                var iframeWin = window[layero.find('iframe')[0]['name']];//得到iframe页的窗口对象，执行iframe页的方法：
		                var ids = iframeWin.getVal();//调用子页面的方法，得到子页面返回的ids
		                $("#department").val(ids);
		                layer.close(index);//需要手动关闭窗口
					}
				})
			})
		})
	</script>
</body>
</html>
